import React from 'react';
import classNames from 'classnames';
import './index.less';

const backW = require('shared/static/back_w.png');
const backB = require('shared/static/back_b.png');

export default class Nav extends React.PureComponent {
  redirect = () => {
    const { history } = this.props;
    if (history) {
      history.goBack();
    } else {
      window.location.href = 'CDMetroScheme://navigateBack';
    }
  }

  render() {
    const { title, style, className, isBlack = true } = this.props;
    return (
      <div className={classNames('subway-header', className)} style={style}>
        <span onClick={this.redirect} className="subway-header-link">
          <img src={isBlack ? backW : backB} alt="" />
        </span>
        <span>{title}</span>
      </div>
    );
  }
}
